package com.chensheng.service;

import com.chensheng.dao.OrderMasterDAO;
import com.chensheng.dto.OrderDTO;
import com.chensheng.model.OrderMaster;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author:ChenSheng
 * @Description:
 * @Date: Created in 下午 14:58 2018/5/15 0015
 */
@Service
public class OrderMasterService {

    @Autowired
    private OrderMasterDAO orderMasterDAO;

    public void saveOne(OrderMaster orderMaster) {
        orderMasterDAO.insertOne(orderMaster);
    }

    public List<OrderMaster> findOneByOpenid(String openid, Integer start, Integer offset) {
        return orderMasterDAO.selectOneByOpenid(openid, start, offset);
    }

    public OrderMaster findOneByOrderId(String orderId) {
        return orderMasterDAO.selectOneByOrderId(orderId);
    }

    public void setOrderStatus(Integer orderStatus, String orderId) {
        orderMasterDAO.updateOrderStatus(orderStatus, orderId);
    }


    public void setPayStatus(Integer payStatus, String orderId){
        orderMasterDAO.updatePayStatus(payStatus, orderId);
    }

    public List<OrderMaster> findAll(Integer start, Integer offset) {
        List<OrderMaster> orderMasterList = orderMasterDAO.selectAll(start, offset);
        return orderMasterList;
    }

    /*
    * 查询有多少条记录
    * */
    public Integer countAll(){
        return orderMasterDAO.countAll();
    }
}
